home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / bin_date.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  69 lines

  1. ; $Id: bin_date.pro,v 1.7 1997/01/15 03:11:50 ali Exp $
  2. ;
  3. ; Copyright (c) 1992-1997, Research Systems, Inc.  All rights reserved.
  4. ;    Unauthorized reproduction prohibited.
  5.  
  6. function bin_date, ascii_time
  7. ;+
  8. ; NAME:
  9. ;    BIN_DATE
  10. ;
  11. ; PURPOSE:
  12. ;    This function converts a standard form ascii date/time string
  13. ;    to a binary string.
  14. ;
  15. ; CATEGORY:
  16. ;    Date/time functions.
  17. ;
  18. ; CALLING SEQUENCE:
  19. ;    Result = BIN_DATE(Asc_time)
  20. ;
  21. ; INPUTS:
  22. ;    Asc_time: the date/time to convert in standard ascii format.
  23. ;          If omitted, use the current date/time.  
  24. ;            Standard form is a 24 character string:
  25. ;            DOW MON DD HH:MM:SS YYYY
  26. ;          where: DOW = day of week, MON = month, DD=day of month,
  27. ;            HH:MM:SS = hour/minute/second, YYYY = year.
  28. ;
  29. ; OUTPUTS:
  30. ;    This function returns a 6 element integer array containing:
  31. ;     Element 0 = year    e.g. 1992
  32. ;        1 = month    1-12
  33. ;        2 = day        1-31
  34. ;        3 = hour    0-23
  35. ;        4 = minute    0-59
  36. ;        5 = second    0-59
  37. ;
  38. ; SIDE EFFECTS:
  39. ;    None.
  40. ;
  41. ; RESTRICTIONS:
  42. ;    None.
  43. ;
  44. ; PROCEDURE:
  45. ;    Straightforward.
  46. ;
  47. ; MODIFICATION HISTORY:
  48. ;     Written by:    DMS /RSI, Jul, 1992.
  49. ;    Modified to use STR_SEP function, DMS, Dec. 1995.
  50. ;       Fixed bug when passed single digit dates
  51. ;            KDB, Nov, 01 1996
  52. ;-
  53.  
  54.  
  55. if n_elements(ascii_time) eq 0 then $
  56.    ascii_time = systime(0)    ;Current time
  57. a_time=strcompress(ascii_time)  ; compress all those spaces to 1
  58. s = str_sep(a_time, ' ')    ;Separate fields
  59. t = str_sep(s[3], ':')        ;Time fields separated by colon
  60. m = where(strupcase(s[1]) eq $    ; = month  - 1
  61.  ['JAN','FEB','MAR','APR', 'MAY', 'JUN', 'JUL', 'AUG','SEP','OCT','NOV','DEC'])
  62. return, [ s[4], $            ;year
  63.     m[0] + 1, $            ;Month
  64.     s[2], $                ;day
  65.     t[0], $                ;Hour
  66.     t[1],$                ;minute
  67.     t[2]]                ;second
  68. end
  69.